package edu.pku.sei.modeler.neditor.action;

import org.eclipse.gef.ContextMenuProvider;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.gef.ui.actions.GEFActionConstants;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.actions.ActionFactory;

public class NotationContextMenuProvider extends ContextMenuProvider {
	private ActionRegistry actionRegistry;
	public NotationContextMenuProvider(EditPartViewer viewer, ActionRegistry registry) {
		super(viewer);
		actionRegistry = registry;
	}

	@Override
	public void buildContextMenu(IMenuManager menu) {
    	menu.add(new Separator(GEFActionConstants.GROUP_UNDO));
    	menu.add(new Separator(GEFActionConstants.GROUP_EDIT));
        menu.appendToGroup(GEFActionConstants.GROUP_UNDO,getAction(ActionFactory.UNDO.getId()));
        menu.appendToGroup(GEFActionConstants.GROUP_UNDO, getAction(ActionFactory.REDO.getId()));
        
        menu.appendToGroup(GEFActionConstants.GROUP_EDIT, 
        		getAction(MappingAttributeAction.MAPPING_ATTRIBUTE_ID));
	}
	private IAction getAction(String actionId) {
        IAction act = null;
        act = actionRegistry.getAction(actionId);
        /*if(act==null)
        	act = userDefineActionRegistry.getAction(actionId);*/
        return act;
    }
}
